Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

714
Vistas
Move this array "sort" operation to a separate statement. angular 10

t get this message : 'Move this array "sort" operation to a separate statement'

if (isDefined(this.#Type.externalControls)){
  this.#Type.externalControls = this.#Type.externalControls.sort(sortFn);
  this.#Type.externalControls.forEach((control: ITypeControl) => {
    externalForm.push(new FormControl(control));
  });
}

please help me to resolve the issue.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

What .sort does is, it sorts the array it's called on in place, and then returns that array. Assigning the return value of .sort to a new variable could well cause confusion, because now you (may) have two references to the same exact (now sorted) array, rather than a reference to a sorted array and a reference to an unsorted array.

That is

const arr = getArr();
const sortedArr = arr.sort();

is confusing, because arr === sortedArr.

The warning is telling you to not use the return value of .sort, to avoid confusing yourself. Change

this.#Type.externalControls = this.#Type.externalControls.sort(sortFn);

to

this.#Type.externalControls.sort(sortFn);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda